<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %><%--
  Created by IntelliJ IDEA.
  User: 吧
  Date: 2020/12/1
  Time: 14:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>插入教师信息</title>
</head>
<%
    Class.forName("com.mysql.jdbc.Driver");
    String url="jdbc:mysql://localhost:3306/lixiuying";
    Connection connection= DriverManager.getConnection(url,"root","root");
    String sql="insert teacher values(?,?,?,?,?,?,?)";
    PreparedStatement pstm=connection.prepareStatement(sql);
    pstm.setInt(1,Integer.parseInt(request.getParameter("InsertId")));
    pstm.setString(2,request.getParameter("InsertName"));
    pstm.setInt(3,Integer.parseInt(request.getParameter("InsertAge")));
    pstm.setInt(4,Integer.parseInt(request.getParameter("InsertSex")));
    pstm.setString(5,request.getParameter("InsertTel"));
    pstm.setString(6,request.getParameter("InsertEmail"));
    pstm.setString(7,request.getParameter("InsertAddress"));
    int count=pstm.executeUpdate();
    if (count>0)
    {
        out.print("<h2>操作成功,即将返回教师信息页面</h2>");
        response.setHeader("refresh","3,url=SelectNews.jsp");
    }
    else
    {
        out.print("<h2>操作失败,即将返回教师信息页面</h2>");
        response.setHeader("refresh","3,url=SelectNews.jsp");
    }

%>
</html>
